package com.dfbz.springboot_project.mapper;

import com.dfbz.springboot_project.entity.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@org.apache.ibatis.annotations.Mapper
public interface RoleMapper extends Mapper<Role> {
    @Select("SELECT " +
            " p.privilege_name " +
            "FROM " +
            " privilege p, " +
            " role_privilege rp " +
            "WHERE " +
            " p.privilege_id = rp.privilege_id " +
            "AND rp.role_id = #{rid}")
    List<String> selectPriByRid(Integer rid);

    @Select("SELECT " +
            " r.* " +
            "FROM " +
            " admin_role ar, " +
            " role r " +
            "WHERE " +
            " ar.role_id = r.role_id " +
            "AND ar.admin_id = #{Aid}")
    List<Role> selectRolesByAid(Integer Aid);
    @Delete("DELETE  " +
            "FROM " +
            " role  " +
            "WHERE " +
            " role.role_id =#{Rid}")
    void deleteById(Integer Rid);
}
